import axios from "axios";

axios.defaults.baseURL = "http://120.53.31.103:84/";
axios.interceptors.request.use((config) => {
  config.headers["Authorization"] = sessionStorage.getItem("token");
  return config;
});

axios.interceptors.response.use((config) => {
  switch (config.data.code) {
    case 200:
    case 201:
      if (config.headers.newtoken) {
        sessionStorage.setItem("token", config.headers.newtoken);
      } else {
        if (typeof config.data.Data == "string") {
          sessionStorage.setItem("token", config.data.Data);
        }
      }
      return Promise.resolve(config.data);
    default:
      return Promise.reject(config.data.Message);
  }
});
export default {
  // 登录
  logins(info) {
    return axios.post("/api/adminUser/login", info);
  },
};
